package com.lhb.controller;

import com.lhb.pojo.BaseResp;
import com.lhb.pojo.ClassIfy;
import com.lhb.pojo.Teacher;
import com.lhb.service.ClassIfyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.10.10 下午 14:45
 */
@RestController
@RequestMapping("classify")
public class ClassIfyController {
    @Resource
    ClassIfyService classIfyService;

    @RequiresPermissions(value = {"CLASSIFY_FINDALL"})
    @RequestMapping("/findAll")
    public BaseResp findAll() {
        return classIfyService.findAll();
    }

    @RequestMapping(value = "/findAllPage", method = RequestMethod.GET)
    public BaseResp findAllPage(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit) {
        BaseResp all = classIfyService.findAllPage(page, limit);
        return all;
    }

    @RequiresPermissions(value = {"CLASSIFY_DELETE"})
    @RequestMapping("/del")
    public BaseResp delete(@RequestParam("id") Integer id) {
        int del = classIfyService.del(id);
        BaseResp baseResp = new BaseResp();
        baseResp.setCode(1);
        baseResp.setMsg("删除成功");
        return baseResp;
    }

    //新增
    @RequiresPermissions(value = {"CLASSIFY_INSERT"})
    @RequestMapping("/insertclassify")
    public BaseResp insertCourse(@RequestBody ClassIfy classIfy) {
        return classIfyService.insertclassify(classIfy);
    }

    //修改
    @RequiresPermissions(value = {"CLASSIFY_UPDATE"})
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResp updateclassify(@RequestBody ClassIfy classIfy) {
        System.out.println(classIfy);
        return classIfyService.update(classIfy);
    }


}